home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 7.6 KB | 255 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: EmbedFra.cpp
- // Release Version: $ 1.0d11 $
- //
- // Author: M.Boetcher
- //
- // Copyright: © 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "Embed.hpp"
-
- #ifndef EMBEDFRAME_H
- #include "EmbedFra.h"
- #endif
-
- #ifndef EMBEDPART_H
- #include "EmbedPar.h"
- #endif
-
- #ifndef EMBEDPROXY_H
- #include "EmbedPxy.h"
- #endif
-
- #ifndef EMBEDCMD_H
- #include "EmbedCmd.h"
- #endif
-
- // ----- Framework Includes -----
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWPRESEN_H
- #include "FWPresen.h"
- #endif
-
- #ifndef FWPXYFRM_H
- #include "FWPxyFrm.h"
- #endif
-
- // ----- OS Layer Includes -----
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h"
- #endif
-
- #ifndef FWMNUBAR_H
- #include "FWMnuBar.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_Module_OpenDoc_Commands_defined
- #include <CmdDefs.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- //========================================================================================
- // Runtime information
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfembed
- #endif
-
- //========================================================================================
- // CLASS CEmbedFrame
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CEmbedFrame::CEmbedFrame
- //----------------------------------------------------------------------------------------
-
- CEmbedFrame::CEmbedFrame(Environment* ev, ODFrame* odFrame, FW_CPresentation* presentation, CEmbedPart* part) :
- FW_CEmbeddingFrame(ev, odFrame, presentation, part),
- fPart(part)
- {
- SetDroppable(ev, TRUE);
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedFrame::~CEmbedFrame
- //----------------------------------------------------------------------------------------
-
- CEmbedFrame::~CEmbedFrame()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedFrame::Draw
- //----------------------------------------------------------------------------------------
-
- void CEmbedFrame::Draw(Environment* ev, ODFacet* odFacet, ODShape* invalidShape)
- {
- FW_CViewContext vc(ev, this, odFacet, invalidShape);
-
- FW_CRectShape::RenderRect(vc, GetBounds(ev), FW_kFill, FW_kRGBBlue);
- }
-
- //---------------------------------------------------------------------------------------
- // CEmbedFrame::DoAdjustMenus
- //---------------------------------------------------------------------------------------
-
- FW_Boolean CEmbedFrame::DoAdjustMenus(Environment* ev, FW_CMenuBar* menuBar, FW_Boolean hasMenuFocus, FW_Boolean isRoot)
- {
- if (hasMenuFocus)
- {
- // Check clipboard for a part to paste
- menuBar->EnableCommand(ev, kODCommandPaste, HasPropertyOnClipboard(ev, kODPropContentFrame, NULL));
-
- // If an embedded part is selected, change Copy menu item to "Copy Part"
- if (GetPresentation(ev)->GetSelection(ev)->IsEmpty(ev))
- menuBar->SetItemString(ev, kODCommandCopy, FW_CString32("Copy"));
- else
- menuBar->SetItemString(ev, kODCommandCopy, FW_CString32("Copy Part"));
- }
-
- return FALSE;
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedFrame::EmbedSingleFrame
- //----------------------------------------------------------------------------------------
-
- void CEmbedFrame::EmbedSingleFrame(Environment* ev,
- ODPart* odEmbeddedPart,
- ODFrame* odEmbeddedFrame,
- ODShape* suggestedFrameShape)
- {
- FW_UNUSED(suggestedFrameShape);
-
- // ----- Remove existing embedded part -----
- GetPresentation(ev)->GetSelection(ev)->ClearSelection(ev);
-
- // ----- Calculate the frame shape -----
- FW_CAcquiredODShape aqFrameShape = MakeFrameShape(ev);
-
- // ----- Create the proxy -----
- CEmbedProxy* newProxy = new CEmbedProxy(ev, fPart);
-
- // ----- Embed the Part/Frame -----
- GetPresentation(ev)->Embed(ev,
- odEmbeddedPart,
- odEmbeddedFrame,
- newProxy,
- aqFrameShape,
- FW_CPart::gViewAsFrameToken,
- NULL, // no presentation
- 0, // group id
- FALSE); // sub-frame?
-
- // ----- Set the proxy -----
- fPart->SetProxy(ev, newProxy);
-
- // ----- Make sure frame gets redrawn ----
- GetPresentation(ev)->Invalidate(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedFrame::MakeFrameShape
- //----------------------------------------------------------------------------------------
- // Returns a new shape equals to my frame shape inset by eight pixels. Otherwise I can't drop
- // anything
-
- ODShape* CEmbedFrame::MakeFrameShape(Environment* ev)
- {
- FW_CRect bounds = GetBounds(ev);
- bounds.Inset(FW_IntToFixed(8), FW_IntToFixed(8));
- bounds.Place(FW_kFixed0, FW_kFixed0); // Frame shape always zero based
- return ::FW_NewODShape(ev, bounds);
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedFrame::CreateEmbeddedFacet
- //----------------------------------------------------------------------------------------
-
- ODFacet* CEmbedFrame::CreateEmbeddedFacet(Environment* ev,
- ODFacet* embeddingFacet,
- FW_MProxy* proxy,
- ODFrame* embeddedFrame,
- ODShape* proposedClipShape)
- {
- FW_CAcquiredODTransform aqExternalTransform = ::FW_NewODTransform(ev, FW_CPoint(FW_IntToFixed(8), FW_IntToFixed(8)));
-
- return embeddingFacet->CreateEmbeddedFacet(ev,
- embeddedFrame,
- proposedClipShape,
- aqExternalTransform,
- NULL, // Canvas
- NULL, // biasCanvas
- NULL, // siblingFacet
- kODFrameInFront);
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedFrame::FrameShapeChanged
- //----------------------------------------------------------------------------------------
- // Change the frame shape of the embedded frame to be the same as mine
-
- void CEmbedFrame::FrameShapeChanged(Environment* ev)
- {
- // Must call inherited so our "view" superclass gets adjusted.
- FW_CFrame::FrameShapeChanged (ev);
-
- CEmbedProxy* proxy = fPart->GetProxy(ev);
- if (proxy != NULL)
- {
- ODFrame* embeddedFrame = proxy->GetEmbeddedFrame(ev, this);
-
- FW_CAcquiredODShape frameShape = MakeFrameShape(ev);
- embeddedFrame->ChangeFrameShape(ev, frameShape, NULL);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedFrame::NewEditCommand
- //----------------------------------------------------------------------------------------
-
- FW_CEditCommand* CEmbedFrame::NewEditCommand(Environment* ev, ODCommandID commandID)
- {
- FW_Boolean undoAble = TRUE;
- if (commandID == kODCommandPasteAs)
- undoAble = FALSE;
-
- return FW_NEW(CEmbedEditCommand, (ev, commandID,
- (CEmbedPart*)this->GetPart(ev),
- this,
- GetPresentation(ev)->GetSelection(ev),
- undoAble));
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedFrame::NewDropCommand
- //----------------------------------------------------------------------------------------
-
- FW_CDropCommand* CEmbedFrame::NewDropCommand(Environment* ev,
- FW_CFrame* frame,
- ODDragItemIterator* dropInfo,
- ODFacet* odFacet,
- const FW_CPoint& dropPoint)
- {
- return FW_NEW(CProxyDropCommand, (ev, (CEmbedPart*)this->GetPart(ev), this,
- dropInfo, odFacet, dropPoint));
- }
-